<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD><TITLE>Tcl_GetOpenFile manual page - Tcl Library Procedures</TITLE>
<link rel="stylesheet" href="../docs.css" type="text/css" media="all">
</HEAD>
<BODY><H2><a href="../contents.htm">Tcl8.6.11/Tk8.6.11 Documentation</a> <small>&gt;</small> <a href="contents.htm">Tcl C API</a> <small>&gt;</small> GetOpnFl</H2>
<H3><A HREF="../UserCmd/contents.htm">Tcl/Tk Applications</A> | <A HREF="../TclCmd/contents.htm">Tcl Commands</A> | <A HREF="../TkCmd/contents.htm">Tk Commands</A> | <A HREF="../ItclCmd/contents.htm">[incr Tcl] Package Commands</A> | <A HREF="../SqliteCmd/contents.htm">SQLite3 Package Commands</A> | <A HREF="../TdbcCmd/contents.htm">TDBC Package Commands</A> | <A HREF="../TdbcmysqlCmd/contents.htm">tdbc::mysql Package Commands</A> | <A HREF="../TdbcodbcCmd/contents.htm">tdbc::odbc Package Commands</A> | <A HREF="../TdbcpostgresCmd/contents.htm">tdbc::postgres Package Commands</A> | <A HREF="../TdbcsqliteCmd/contents.htm">tdbc::sqlite3 Package Commands</A> | <A HREF="../ThreadCmd/contents.htm">Thread Package Commands</A> | <A HREF="../TclLib/contents.htm">Tcl C API</A> | <A HREF="../TkLib/contents.htm">Tk C API</A> | <A HREF="../ItclLib/contents.htm">[incr Tcl] Package C API</A> | <A HREF="../TdbcLib/contents.htm">TDBC Package C API</A></H3>
<H3><A NAME="M2">NAME</A></H3>
Tcl_GetOpenFile &mdash; Return a FILE* for a channel registered in the given interpreter (Unix only)
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>#include &lt;tcl.h&gt;</B><BR>
int<BR>
<B>Tcl_GetOpenFile</B>(<I>interp, chanID, write, checkUsage, filePtr</I>)<BR>
<H3><A NAME="M4">ARGUMENTS</A></H3>
<DL class="arguments">
<DT><A HREF="../TclLib/Interp.htm">Tcl_Interp</A> <B>*interp</B> (in)<DD>
Tcl interpreter from which file handle is to be obtained.
<P><DT>const char <B>*chanID</B> (in)<DD>
String identifying channel, such as <B><A HREF="../TclLib/GetStdChan.htm">stdin</A></B> or <B>file4</B>.
<P><DT>int <B>write</B> (in)<DD>
Non-zero means the file will be used for writing, zero means it will
be used for reading.
<P><DT>int <B>checkUsage</B> (in)<DD>
If non-zero, then an error will be generated if the file was not opened
for the access indicated by <I>write</I>.
<P><DT>ClientData <B>*filePtr</B> (out)<DD>
Points to word in which to store pointer to FILE structure for
the file given by <I>chanID</I>.
<P></DL>
<H3><A NAME="M5">DESCRIPTION</A></H3>
<B>Tcl_GetOpenFile</B> takes as argument a file identifier of the form
returned by the <B><A HREF="../TclCmd/open.htm">open</A></B> command and
returns at <I>*filePtr</I> a pointer to the FILE structure for
the file.
The <I>write</I> argument indicates whether the FILE pointer will
be used for reading or writing.
In some cases, such as a channel that connects to a pipeline of
subprocesses, different FILE pointers will be returned for reading
and writing.
<B>Tcl_GetOpenFile</B> normally returns <B><A HREF="../TclCmd/catch.htm">TCL_OK</A></B>.
If an error occurs in <B>Tcl_GetOpenFile</B> (e.g. <I>chanID</I> did not
make any sense or <I>checkUsage</I> was set and the file was not opened
for the access specified by <I>write</I>) then <B><A HREF="../TclCmd/catch.htm">TCL_ERROR</A></B> is returned
and the interpreter's result will contain an error message.
In the current implementation <I>checkUsage</I> is ignored and consistency
checks are always performed.
<P>
Note that this interface is only supported on the Unix platform.

<H3><A NAME="M6">KEYWORDS</A></H3>
<A href="../Keywords/C.htm#channel">channel</A>, <A href="../Keywords/F.htm#file handle">file handle</A>, <A href="../Keywords/P.htm#permissions">permissions</A>, <A href="../Keywords/P.htm#pipeline">pipeline</A>, <A href="../Keywords/R.htm#read">read</A>, <A href="../Keywords/W.htm#write">write</A>
<div class="copy">Copyright &copy; 1996-1997 Sun Microsystems, Inc.
</div>
</BODY></HTML>
